<?php
class Sys_industry_model extends CI_Model {

	public function __construct(){
		parent::__construct();
		$this->db = $this->load->database('default',true);
	}

	/**
	 * 查询区域列表
	 * @param string $parent_id
	 */
	public function  query_industrys($parent_id) {
		$sql ="select * from sys_industry where industry_status ='1'and  parent_id ='$parent_id' order by industry_id asc";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->result_array();
		}
	}

	public function query_parent_id($industry_id){
		$sql ="select parent_id from sys_industry where industry_status ='1'and  industry_id ='$industry_id' limit 1";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->row_array();
		}
	}

	public function query_industry_info($industry_id){
		$sql ="select * from  sys_industry where industry_status ='1'and  industry_id ='$industry_id' limit 1";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->row_array();
		}
	}

	public function query_industry_info_by_name($industry_name){
		$sql ="select * from  sys_industry where industry_status ='1'and  industry_name ='$industry_name' limit 1";
		$query	=$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->row_array();
		}
	}
	public function insert_industry($industry){
		$industry['industry_status']=1;
		$this->db->insert('sys_industry',$industry);
	}
	public function update_industry($industry,$industry_id){
		$this->db->where('industry_id',$industry_id);
		$this->db->update('sys_industry',$industry);
	}

	public function set_delete_industry($industry_id){
		$sql ="update sys_industry set industry_status ='0' where industry_id='$industry_id'";
		$this->db->query($sql);
	}
	
}
?>